using System;
using System.Collections.Generic;
using System.Text;
using DTO;
using DAL;

namespace BUS
{
   public class tbkhachhangBUS
    {
        static public string error = "";
        public static void Insert(tbkhachhangDTO kh)
        {
            tbkhachhangDAL tbkhachhangDAL = new tbkhachhangDAL();
            tbkhachhangDAL.Insert(kh);
        }
       public static void Update(tbkhachhangDTO kh)
        {
            tbkhachhangDAL tbkhachhangDAL = new tbkhachhangDAL();
            tbkhachhangDAL.Update(kh);
            error = tbkhachhangDAL.error;
        }
        public static void Delete(int iD)
        {
            tbkhachhangDAL khachhangDAL = new tbkhachhangDAL();
            khachhangDAL.Delete(iD);
        }
        public static tbkhachhangcollection GET(string Where, int PageIndex, int PageSize,
                                        string OrderBy, string OrderDirection,
                                        out int TotalRecords)
        {
            tbkhachhangDAL tbkhachhangDAL = new tbkhachhangDAL();
            return tbkhachhangDAL.GET(Where, PageIndex, PageSize,
                            OrderBy, OrderDirection, out TotalRecords);
        }
       public static tbkhachhangDTO GetByID(int iD)
       {
           int t = 0;
           tbkhachhangDAL tbkhachhangDAL = new tbkhachhangDAL();
           tbkhachhangcollection khcolect = tbkhachhangDAL.GET("where " + tbkhachhangcolumn.Makh.ToString() + " = " + iD.ToString(), 0, 0,
               tbkhachhangcolumn.Tenkh.ToString(), "ASC", out t);
           if (khcolect.Count == 1)
               return khcolect[0];
           return null;
       }
       public static tbkhachhangDTO GetByEmail(string email)
       {
           tbkhachhangDAL khDAL = new tbkhachhangDAL();
           return khDAL.GetByEmail(email);
       }
    }
}
